package com.jscm.openmodule;

import com.jscm.openprocess.OpenProcessListView;
import com.jscm.showdata.SelectDataView;
import com.jscm.showdata.TagMomeory;
import com.scm.all.export.ByteUtils;
import com.scm.all.export.SystemUtils;
import com.scm.all.export.WindowOperationUtils;
import com.scm.all.pfunc.MemoryCallBack;
import com.scm.x64.export.MemoryOperationUtilsX64;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;

/**
 * 菜单按钮打开模块句柄
 */
public class OpenModuleBtn {
    public static Button button = new Button();
    static {
        init();
    }

    private static void init() {
        button.setPrefWidth(40);
        button.setPrefHeight(40);
        button.setDisable(true);
        button.setBackground(new Background(new BackgroundImage(new Image("btn/btn5.png"), BackgroundRepeat.NO_REPEAT ,BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, BackgroundSize.DEFAULT)));
        button.setOnMouseEntered(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                button.setStyle("-fx-border-radius: 5px;-fx-border-color: #ffffff");
            }
        });
        button.setOnMouseExited(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                button.setStyle("-fx-border-radius: none");
            }
        });
        button.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                if(OpenProcessListView.processHandler > 0){
                    OpenModuleListView.init();
                    OpenModuleWindow.stage.show();
                }else {
                    OpenModuleWindow.stage.hide();
                    SystemUtils.messageBoxExW(WindowOperationUtils.windowGetHwnd(),"请先打开进程","温馨提示",0);
                }

            }
        });
    }
}
